package com.tx.dao;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.tx.pojo.Employee;

public class Main {
	public static void main(String[] args) throws IOException {
	
		
		String resource = "conf.xml";
		InputStream inputStream = Resources.getResourceAsStream(resource);
	
	
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
		System.out.println(1);
		SqlSession session = sqlSessionFactory.openSession();
		
		EmployeeDAO dao =session.getMapper(EmployeeDAO.class);
		//Employee emp =dao.selectEmpById(2);		
		//System.out.println(emp);
		
		/*
		 * Employee emp =new Employee(); emp.setId(2); emp.setLast_name("dgxnew");
		 * 	dao.updateEmp(emp);
		 */
		
		/*插入
		 * Employee emp =new Employee(); emp.setLast_name("ddd"); emp.setGender("nv");
		 * emp.setEmail("dengg@126.com"); emp.setDid(23432); dao.insertEmp(emp);
		 */
		
		/* 多参数select
		 *  Employee emp =dao.selectEmpByIdAndLastName(3,"ew"); 
		 *  System.out.println(emp);
		 *  */
		
		
		
		Employee emp =dao.selectEmpByIdAndLastName(3,"ew"); 
		System.out.println(emp);
	 session.commit(); 
	 session.close();
				
		/*
		 * Map<String,Object> map= new HashMap<String,Object>(); map.put("abc", 3);
		 * map.put("bcd","ew");
		 * 
		 * Employee e =dao.selectEmpByIdAndLastName(map);
		 * 
		 * 
		 * System.out.println(e);
		 */
	
	
	
		
		
		

			
	}

}
